# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=pixman
pkgver=0.43.4
pkgrel=1
pkgdesc="Low-level pixel manipulation library"
url="https://gitlab.freedesktop.org/pixman"
arch="all"
license="MIT"
makedepends="meson libpng-dev linux-headers"
subpackages="$pkgname-static $pkgname-dev $pkgname-dbg"
source="https://www.x.org/releases/individual/lib/pixman-$pkgver.tar.xz
	binutils-asm.patch
	"

case "$CARCH" in
	# segfault in multiple tests
	riscv64) options="!check" ;;
esac


build() {
	case "$CARCH" in
	armhf)
		# target-specific builtin not available
		local lto=false
		;;
	*)
		local lto=true
		;;
	esac
	# We need to increase the stacksize here: https://gitlab.gnome.org/GNOME/librsvg/-/issues/595
	LDFLAGS="$LDFLAGS -Wl,-z,stack-size=2097152" \
	# auto-features=auto: a lot of features are architecture dependent
	abuild-meson \
		--auto-features=auto \
		-Db_lto=$lto \
		-Ddefault_library=both \
		-Dlibpng=enabled \
		-Ddemos=disabled \
		-Dtests="$(want_check && echo enabled || echo disabled)" \
		. output
	meson compile -C output
}

check() {
	meson test --no-rebuild --print-errorlogs -C output -t 10
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

sha512sums="
b40fb05bd58dc78f4e4e9b19c86991ab0611b708657c9a7fb42bfe82d57820a0fde01a34b00a0848a41da6c3fb90c2213942a70f435a0e9467631695d3bc7e36  pixman-0.43.4.tar.xz
b24844daa980b9e90f83344657a15c02d59fc130695b5f03e4349d41207148455ccf83a4b3ceb9e20ba9b23aab3e76df351ef897d83f63d1c091e98e2eb65d41  binutils-asm.patch
"
